﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GsifWeb4
{
    #region baseclass
    public class Statuses
    {
        public static StatusValue GetStatusFromText(List<StatusValue> AllStatuses, string text)
        {
            foreach (StatusValue status in AllStatuses)
            {
                if (status.Text == text)
                    return status;
            }
            return null;
        }

        public static StatusValue GetStatusFromDbValue(List<StatusValue> AllStatuses, string dbValue)
        {
            foreach (StatusValue status in AllStatuses)
            {
                if (status.IsDbValue(dbValue))
                    return status;
            }
            return null;
        }

        public static string GetTextFromDbValue(List<StatusValue> AllStatuses, string dbValue)
        {
            foreach (StatusValue status in AllStatuses)
            {
                if (status.IsDbValue(dbValue))
                    return status.Text;
            }

            return "";
        }
    }

    public class StatusValue
    {
        public string Text { get; private set; }
        public string DbValue { get; private set; }

        public StatusValue(string dbValue, string text)
        {
            DbValue = dbValue;
            Text = text;
        }

        public override string ToString()
        {
            if (Text == null)
                return "";

            return Text;
        }

        public bool IsDbValue(string dbValue)
        {
            return DbValue.Equals(dbValue, StringComparison.InvariantCultureIgnoreCase);
        }
    }
    #endregion

    public class HomeOrAway : Statuses
    {
        public static StatusValue Home = new StatusValue("H", "Hemma");
        public static StatusValue Away = new StatusValue("B", "Borta");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Home, Away };
    }

    public class MatchType : Statuses
    {
        public static StatusValue League = new StatusValue("serie", "Seriematch");
        public static StatusValue Friendly = new StatusValue("träning", "Träningsmatch");
        public static StatusValue Cup = new StatusValue("Cup", "Cup");
        public static StatusValue Indoor = new StatusValue("inomhus", "Inomhus");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { League, Friendly, Cup, Indoor};
    }

    public class Team : Statuses
    {
        public static StatusValue MenA = new StatusValue("HerrA", "HerrA");
        public static StatusValue MenC = new StatusValue("HerrC", "HerrC");
        public static StatusValue WomenA = new StatusValue("DamA", "DamA");
        public static StatusValue WomenB = new StatusValue("DamB", "DamB");

        public static StatusValue All = new StatusValue("Alla", "Alla");

        public static List<StatusValue> AllTeams = new List<StatusValue>() { MenA, MenC, WomenA, WomenB};
        public static List<StatusValue> AllTeamsIncludingAllOption = new List<StatusValue>() { All, MenA, MenC, WomenA, WomenB };
    }

    public class ForumType : Statuses
    {
        public static StatusValue Main = new StatusValue("0", "Klotterplank");
        public static StatusValue MenA = new StatusValue("1", "HerrA");
        public static StatusValue MenC = new StatusValue("2", "HerrC");
        public static StatusValue WomenA = new StatusValue("3", "DamA");
        public static StatusValue WomenB = new StatusValue("4", "DamB");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Main, MenA, WomenA, WomenB };
    }

    public class StatExist : Statuses
    {
        public static StatusValue Yes = new StatusValue("Y", "Ja");
        public static StatusValue No = new StatusValue("N", "Nej");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Yes, No };
    }

    public class InActivePlayer : Statuses
    {
        public static StatusValue Active = new StatusValue("", "Aktiv");
        public static StatusValue InActive = new StatusValue("on", "Inaktiv");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Active, InActive };
    }

    public class Position : Statuses
    {
        public static StatusValue Coach = new StatusValue("0", "Tränare");
        public static StatusValue GoalKeeper = new StatusValue("1", "Målvakt");
        public static StatusValue Defender = new StatusValue("2", "Försvarare");
        public static StatusValue Midfielder = new StatusValue("3", "Mittfältare");
        public static StatusValue Forward = new StatusValue("4", "Anfallare");
        public static StatusValue Substituter = new StatusValue("5", "Avbytare");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Coach, GoalKeeper, Defender, Midfielder, Forward, Substituter };
    }

    public class Sex : Statuses
    {
        public static StatusValue Male = new StatusValue("M", "Man");
        public static StatusValue Female = new StatusValue("K", "Kvinna");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Male, Female};
    }

    public class StatisticType : Statuses
    {
        public static StatusValue Match = new StatusValue("Ma", "Match");
        public static StatusValue Training = new StatusValue("Tr", "Träning");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Match, Training };
    }

    public class ManOfTheMatch : Statuses
    {
        public static StatusValue Yes = new StatusValue("on", "Ja");
        public static StatusValue No = new StatusValue("", "Nej");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Yes, No };
    }

    public class LineUp : Statuses
    {
        // 11-manna
        public static StatusValue Eleven_442 = new StatusValue("442", "4-4-2");
        public static StatusValue Eleven_451 = new StatusValue("451", "4-5-1");
        public static StatusValue Eleven_433 = new StatusValue("433", "4-3-3");
        public static StatusValue Eleven_352 = new StatusValue("352", "3-5-2");
        public static StatusValue Eleven_343 = new StatusValue("343", "3-4-3");

        // 7-manna
        public static StatusValue Seven_321 = new StatusValue("321", "3-2-1");
        public static StatusValue Seven_231 = new StatusValue("231", "2-3-1");
        public static StatusValue Seven_222 = new StatusValue("222", "2-2-2");

        // Innefotboll
        public static StatusValue Indoor_22 = new StatusValue("22", "2-2");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Eleven_442, Eleven_451, Eleven_433, Eleven_352, Eleven_343,
        Seven_321, Seven_231, Seven_222, Indoor_22};
    }

    public class Permission : Statuses
    {
        public static StatusValue Player = new StatusValue("Spelare", "Spelare");
        public static StatusValue Webred = new StatusValue("Webred", "Webred");
        public static StatusValue Webmaster = new StatusValue("Webmaster", "Webmaster");

        public static List<StatusValue> AllPermissions = new List<StatusValue>() { Player, Webred, Webmaster };
    }

    public class InjuredPlayer : Statuses
    {
        public static StatusValue Injured = new StatusValue("on", "Skadad");
        public static StatusValue NotInjured = new StatusValue("", "Ej skadad");

        public static List<StatusValue> AllStatuses = new List<StatusValue>() { Injured, NotInjured };
    }
}